import {gql} from "@apollo/client";

export const GET_ROLES = gql`
query MyQuery {
  sysAuth {
    roles {
      authorities {
        authorityName
        createTime
        id
        updateTime
      }
      createTime
      id
      roleName
      updateTime
    }
  }
}
`;

export const CREATE_ROLE = gql`
mutation MyMutation(
  $roleName: String
  $authorityIds: [String!]
) {
  sysAuth {
    addRole(input: {roleName: $roleName, authorityIds: $authorityIds}) {
      createTime
      authorities {
        authorityName
        createTime
        id
        updateTime
      }
      id
      roleName
      updateTime
    }
  }
}
`;


export const GET_AUTHORITIES = gql`
query MyQuery {
  sysAuth {
    authorities {
      authorityName
      createTime
      id
      updateTime
    }
  }
}
`;

export const DELETE_ROLE = gql`
mutation MyMutation($id: String) {
  sysAuth {
    deleteRole(id: $id)
  }
}
`;

export const UPDATE_ROLE = gql`
mutation MyMutation(
  $id: String
  $authorityIds: [String!]
  $roleName: String
) {
  sysAuth {
    updateRole(
      input: {id: $id, roleName: $roleName, authorityIds: $authorityIds}
    ) {
      authorities {
        authorityName
        createTime
        id
        updateTime
      }
      createTime
      id
      roleName
      updateTime
    }
  }
}
`;



export const BIND_USER_AUTHORITIES = gql`
mutation MyMutation2(
  $authorityIds: [String!]
  $userId: String
) {
  sysAuth {
    bindUserAuthority(input: {authorityIds: $authorityIds, userId: $userId})
  }
}
`;

export const BIND_USER_ROLES = gql`
mutation MyMutation2(
  $userId: String
  $roleIds: [String!]
) {
  sysAuth {
    bindUserRole(input: {userId: $userId, roleIds: $roleIds})
  }
}
`;

